package com.cc8w.admins.service;


import com.cc8w.admins.mapper.ProductClassMapper;
import com.cc8w.admins.mapper.UserMapper;
import com.cc8w.entity.AttributeValuesEntity;
import com.cc8w.entity.CategoryEntity;
import com.cc8w.entity.GoodsEntity;
import com.cc8w.entity.ProductAttributeEntity;
import com.cc8w.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.DecimalFormat;
import java.util.List;

@Service("productClassService")
@Transactional
public class ProductClassService {
    @Autowired
    @Qualifier("productClassMapper")
    private ProductClassMapper productClassMapper;

    //获得分类列表
    public List<PageData> queryTypeList(){
       return productClassMapper.queryTypeList();
    }

    //获得单个分类信息
    public PageData queryProductType(int type_id){
        return productClassMapper.queryProductType(type_id);
    }
    public int updateProductType(int type_id,String model_name,int enable,String attr_group){
        return productClassMapper.updateProductType(type_id,model_name,enable,attr_group);
    }
    //添加分类
    public int addProductType(PageData pageData){
        return productClassMapper.addProductType(pageData);
    }

    //给分类增加属性
    public int insertProductAttribute(PageData pageData){
        return productClassMapper.insertProductAttribute(pageData);
    }
    //分类属性列表(获得属性列表通过对象)
    public List<ProductAttributeEntity> getProductAttributeList(PageData pageData){
        return productClassMapper.getProductAttributeList(pageData);
    }
    //属性的values写值
    public int insertProductAttributeValues(int attr_id,String attr_value){
        return productClassMapper.insertProductAttributeValues(attr_id,attr_value);
    }


    //获得产品分类
    public List<CategoryEntity> getGoodsCat(){

        return productClassMapper.getGoodsCat();
    }

    //写入产品
    public int insertGoods(GoodsEntity goodsEntity){
        return productClassMapper.insertGoods(goodsEntity);
    }
    //写入价格
    public int insertGoodsPrice(int goodsId, String goodsSn,Float goodsPrice, String priceValues){
        return productClassMapper.insertGoodsPrice(goodsId,goodsSn,goodsPrice,priceValues);
    }
    //写产品属性表
    public int insertGoodsAttr(int goodsId,int attrId,int valId,String attrValue){
        return productClassMapper.insertGoodsAttr(goodsId,attrId,valId,attrValue);
    }
    //获取某个属性
    public ProductAttributeEntity getProductAttribute(int attrId){
        return productClassMapper.getProductAttribute(attrId);
    }

    //修改属性名
    public int updateProductAttribute(PageData pageData){
        return productClassMapper.updateProductAttribute(pageData);
    }
    //修改属性值
    public int updateProductAttribute(){
        return productClassMapper.updateProductAttributeValue();
    }
    //查找是否有属性
    public AttributeValuesEntity hasProductAttributeValues(int attr_id,String attr_value){
        return productClassMapper.hasProductAttributeValues(attr_id,attr_value);
    }


}

